#include "..\..\TYPES.H"
#include "TACOLOR.H"

PALETTEENTRY tacolor[64] = {
  { 111, 102, 143, 1 }, {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, { 239, 238,  15, 1 },
  { 239, 142,  15, 1 }, { 239,  78, 111, 1 }, { 239,  14,  15, 1 }, {  15,   0,  15, 1 },
  {  15,   0,  15, 1 }, {  15,   0,  79, 1 }, {  79,  68, 111, 1 }, { 175, 170,  79, 1 },
  {  15, 128,  15, 1 }, {  79,  68, 111, 1 }, { 239, 142,  15, 1 }, {  15,   0,  15, 1 },
  { 111, 102, 143, 1 }, { 239, 238, 239, 1 }, { 239, 238, 239, 1 }, { 239, 238,  15, 1 },
  { 239, 142,  15, 1 }, { 239,  78, 111, 1 }, { 239,  14,  15, 1 }, {  15,   0,  15, 1 },
  {  15,   0,  15, 1 }, {  15,   0,  79, 1 }, {  79,  68, 111, 1 }, { 175, 170,  79, 1 },
  { 111, 102, 143, 1 }, {  79,  68, 111, 1 }, { 239, 142,  15, 1 }, {  15,   0,  15, 1 },
  {  15,   0,  15, 1 }, {  15,   0, 143, 1 }, {  15,   0, 239, 1 }, {  15,  96, 239, 1 },
  {  47, 130, 239, 1 }, { 111, 166, 239, 1 }, { 239, 238, 239, 1 }, { 111,  70,  15, 1 },
  { 175, 106,  79, 1 }, { 239, 174, 143, 1 }, { 143, 136,  15, 1 }, { 239, 238,  15, 1 },
  { 207,  12,  15, 1 }, { 111,   6,  15, 1 }, {  15, 128,  15, 1 }, {  47,  34,  47, 1 },
  {  15,   0,  15, 1 }, {  47,  34,  47, 1 }, {  79,  68,  79, 1 }, { 111, 102, 111, 1 },
  { 143, 136, 143, 1 }, { 175, 170, 175, 1 }, { 207, 204, 207, 1 }, { 239, 238, 239, 1 },
  {  15,   0,  15, 1 }, {  47,  34,  47, 1 }, {  79,  68,  79, 1 }, { 111, 102, 111, 1 },
  { 143, 136, 143, 1 }, { 175, 170, 175, 1 }, { 207, 204, 207, 1 }, { 239, 238, 239, 1 }
};
PALETTEENTRY ta_stage_col[2][8][16] = {
  {
    {
      {  15,   0,  15, 1 }, {  15,   0, 143, 1 }, {  15,   0, 239, 1 }, {  15,  96, 239, 1 },
      {  47, 130, 239, 1 }, { 111, 166, 239, 1 }, { 239, 238, 239, 1 }, { 111,  70,  15, 1 },
      { 175, 106,  79, 1 }, { 239, 174, 143, 1 }, { 143, 136,  15, 1 }, { 239, 238,  15, 1 },
      { 207,  12,  15, 1 }, { 111,   6,  15, 1 }, {  15, 128,  15, 1 }, {  47,  34,  47, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, { 239,  14, 239, 1 }, {  47,   2,  15, 1 },
      { 239, 174,  15, 1 }, { 239, 238, 239, 1 }, { 175,  74,  15, 1 }, { 111,  38,  15, 1 },
      { 143, 232,  15, 1 }, {  15, 160,  15, 1 }, {  15,  96,  15, 1 }, {  15,  64,  15, 1 },
      {  15,   0,  15, 1 }, {  47,  34, 175, 1 }, {  47,  98, 239, 1 }, {  79, 196, 239, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 143, 1 }, { 239,  78, 239, 1 }, { 207,  44, 143, 1 },
      { 143,   8, 111, 1 }, {  79,   4,  79, 1 }, {  47,   2,  15, 1 }, { 239, 238,  15, 1 },
      { 239, 142,  15, 1 }, { 143,  72,  15, 1 }, {  15,   0,  15, 1 }, { 239, 238, 239, 1 },
      {  15, 160, 239, 1 }, {  79,   4, 143, 1 }, {  47,   2, 111, 1 }, {  15,   0,  47, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, {  15,  64,  47, 1 }, {  15,  96,  79, 1 },
      {  15, 128, 111, 1 }, { 111,   6, 175, 1 }, { 175, 106, 239, 1 }, {  15, 160, 143, 1 },
      {  15, 128,  47, 1 }, {  15, 192,  79, 1 }, { 175, 234, 111, 1 }, {  15,  32,  15, 1 },
      { 111, 102,  47, 1 }, { 175, 170,  15, 1 }, {  15,   0,  15, 1 }, { 239, 238, 143, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, {  15,   0,  47, 1 }, { 111, 102, 143, 1 },
      {  47,  34,  79, 1 }, { 239, 238,  79, 1 }, { 239, 142,  79, 1 }, { 143,  40,  47, 1 },
      {  79,   4,  15, 1 }, {  15,  64,  47, 1 }, { 175,  42, 143, 1 }, { 111,   6, 111, 1 },
      {  15,   0,  15, 1 }, { 111, 230, 207, 1 }, {  79, 196, 143, 1 }, {  47, 130, 111, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, { 239,  14,  15, 1 }, {  15,   0,  15, 1 },
      { 111,  70,  15, 1 }, { 143, 200, 239, 1 }, { 239, 174,  15, 1 }, {  15,  32,  15, 1 },
      {  15,  64,  47, 1 }, {  15,  96, 175, 1 }, {  15, 192, 239, 1 }, {  15, 224, 239, 1 },
      {  15,   0,  15, 1 }, {  47,   2,  79, 1 }, { 111,   6, 239, 1 }, { 143, 104, 239, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, { 207, 204,  15, 1 }, { 143, 104,  15, 1 },
      {  79,  36,  15, 1 }, {  15,   0,  15, 1 }, {  47,   2, 111, 1 }, { 111,   6, 207, 1 },
      {  15,  64, 239, 1 }, {  15, 224,  15, 1 }, {  47,  34,  15, 1 }, { 143, 136, 143, 1 },
      {  79,  68,  79, 1 }, {  15,   0,  47, 1 }, { 143,   8,  79, 1 }, { 207,  12, 207, 1 }
    },{
      {  15,   0,  15, 1 }, { 239,  14, 239, 1 }, { 239, 238, 239, 1 }, {  15,  32,  15, 1 },
      {  15, 128,  15, 1 }, {  15, 224,  15, 1 }, {  15,  32,  47, 1 }, {  15,  96,  79, 1 },
      {  15, 160, 143, 1 }, {  15, 224, 239, 1 }, {  47,   2,  15, 1 }, {  15,   0,  15, 1 },
      {  79,   4,  15, 1 }, { 111,   6,  15, 1 }, { 239,  14,  15, 1 }, { 239, 174,  15, 1 }
    }
  },
  {
    {
      {  15,   0,  15, 1 }, {  15,   0, 143, 1 }, {  15,   0, 239, 1 }, {  15,  96, 239, 1 },
      {  47, 130, 239, 1 }, { 111, 166, 239, 1 }, { 239, 238, 239, 1 }, { 111,  70,  15, 1 },
      { 175, 106,  79, 1 }, { 239, 174, 143, 1 }, { 143, 136,  15, 1 }, { 239, 238,  15, 1 },
      { 207,  12,  15, 1 }, { 111,   6,  15, 1 }, {  15, 128,  15, 1 }, {  47,  34,  47, 1 }
    },{
      {  15,   0,  15, 1 }, {  15,   0,  47, 1 }, {  15,   0,  79, 1 }, {  15,   0, 111, 1 },
      {  15,   0, 143, 1 }, {  15,  32,  47, 1 }, {  79,  68,  47, 1 }, {  15,   0, 239, 1 },
      {  15,   0,  15, 1 }, { 175, 170, 143, 1 }, { 143, 168, 239, 1 }, {  79, 132, 239, 1 },
      {  47,  66, 239, 1 }, { 143, 136, 111, 1 }, { 207, 204, 143, 1 }, { 239, 238, 239, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, { 207, 236, 239, 1 }, { 175, 202, 239, 1 },
      { 143, 168, 239, 1 }, { 111, 134, 239, 1 }, {  79, 100, 239, 1 }, { 143, 136, 175, 1 },
      { 111, 102, 111, 1 }, { 175, 106,  79, 1 }, { 207, 140, 111, 1 }, { 239, 206, 143, 1 },
      { 239, 238, 175, 1 }, { 175,  74,  15, 1 }, { 111,  70,  15, 1 }, {  47,  66, 239, 1 }
    },{
      {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, {  15,  32, 239, 1 }, {  15,  64, 239, 1 },
      {  47,  98, 239, 1 }, {  79, 132, 239, 1 }, {  15,   0, 175, 1 }, {  15,   0, 143, 1 },
      {  15,   0, 207, 1 }, {  15,   0,  79, 1 }, {  47, 226, 239, 1 }, { 111, 166, 207, 1 },
      {  79, 132, 175, 1 }, {  15,  64, 143, 1 }, {  15,   0, 239, 1 }, {  15,   0,  15, 1 }
    },{
      {  15,   0,  15, 1 }, {  15,   0,  15, 1 }, { 239, 238, 239, 1 }, { 239, 238, 143, 1 },
      { 207, 172,  79, 1 }, { 207, 140,  79, 1 }, { 143, 104,  79, 1 }, {  79,  36,  47, 1 },
      { 175, 202, 239, 1 }, {  47,  98, 239, 1 }, { 111, 102, 111, 1 }, {  15,  32,  15, 1 },
      {  47,  66, 175, 1 }, {  79, 132,  15, 1 }, {  15,  32, 239, 1 }, { 175, 170, 175, 1 }
    },{
      {  15,   0,  15, 1 }, { 175,  10,  15, 1 }, { 239, 238, 239, 1 }, { 239, 238,  15, 1 },
      { 143, 200,  15, 1 }, {  79, 164,  15, 1 }, {  47,  98,  15, 1 }, {  15,  64,  15, 1 },
      {  15,   0,  79, 1 }, {  15,   0, 143, 1 }, {  15,  32, 207, 1 }, {  15,  64, 239, 1 },
      {  15, 160, 239, 1 }, { 111,   6,  15, 1 }, {  15, 224, 239, 1 }, {  15,   0,  15, 1 }
    },{
      {  15,   0,  15, 1 }, { 175,  10, 239, 1 }, { 239,  14, 111, 1 }, { 239, 142,  15, 1 },
      { 143, 232, 143, 1 }, {  79, 164, 239, 1 }, {  47,  34,  79, 1 }, { 111,   6,  79, 1 },
      { 239, 238, 239, 1 }, { 175, 170, 207, 1 }, { 111, 102, 143, 1 }, {  79,  68, 111, 1 },
      {  47,  98,  15, 1 }, {  79, 164,  15, 1 }, { 207, 204,  15, 1 }, {  15,   0,  15, 1 }
    },{
      {  15,   0,  15, 1 }, {  15,  64,  15, 1 }, {  47,  34,  47, 1 }, {  15,  64,  79, 1 },
      { 239, 238, 239, 1 }, { 239, 206, 143, 1 }, {  15,  96, 111, 1 }, {  79, 132, 143, 1 },
      { 239, 238,  15, 1 }, { 175, 234,  15, 1 }, { 111, 198,  15, 1 }, {  47, 130,  15, 1 },
      {  15,  96,  15, 1 }, { 239, 174,  79, 1 }, { 207, 140,  15, 1 }, { 143,  72,  79, 1 }
    }
  }
};
extern PALETTEENTRY* lpcolorwk;
static short clchgcnt[4];








void TAColorSet(int) { /* Line 120, Address: 0x1001ef0 */
  int i;

  for (i = 0; i < 64; ++i) { /* Line 123, Address: 0x1001ef8 */
    lpcolorwk[i] = tacolor[i]; /* Line 124, Address: 0x1001f04 */
  } /* Line 125, Address: 0x1001f44 */

} /* Line 127, Address: 0x1001f54 */


void TAPicColorSet(int mode, int round) { /* Line 130, Address: 0x1001f70 */
  int i;

  for (i = 0; i < 16; ++i) { /* Line 133, Address: 0x1001f80 */
    lpcolorwk[i + 32] = ta_stage_col[mode][round][i]; /* Line 134, Address: 0x1001f8c */
  } /* Line 135, Address: 0x1001fe8 */

} /* Line 137, Address: 0x1001ff8 */


unsigned short cntplus(unsigned short* work, unsigned short plus_data, unsigned short under_limit, unsigned short upper_limit) { /* Line 140, Address: 0x1002010 */
  if ((*work += plus_data) > upper_limit) *work = under_limit; /* Line 141, Address: 0x1002024 */
  return *work; /* Line 142, Address: 0x1002064 */
} /* Line 143, Address: 0x100206c */




void TAColorChgSP6() { /* Line 148, Address: 0x1002080 */
  unsigned short d0, d5, d6, d7;
  PALETTEENTRY* lpPeDest;
  short i;
  static PALETTEENTRY tbl0[26] = {
    { 239,  78,  15, 1 }, { 239, 142,  15, 1 }, { 239, 206,  15, 1 }, { 175, 234,  79, 1 },
    { 143, 232, 143, 1 }, {  79, 228, 207, 1 }, {  79, 164, 239, 1 }, { 143, 104, 239, 1 },
    { 175,  10, 239, 1 }, { 239,  46, 239, 1 }, { 239,  14, 175, 1 }, { 239,  14, 111, 1 },
    { 239,  14,  47, 1 }, { 239,  78,  15, 1 }, { 239, 142,  15, 1 }, { 239, 206,  15, 1 },
    { 175, 234,  79, 1 }, { 143, 232, 143, 1 }, {  79, 228, 207, 1 }, {  79, 164, 239, 1 },
    { 143, 104, 239, 1 }, { 175,  10, 239, 1 }, { 239,  46, 239, 1 }, { 239,  14, 175, 1 },
    { 239,  14, 111, 1 }, { 239,  14,  47, 1 }
  };
  static PALETTEENTRY tbl1[12] = {
    {  15,   0, 239, 1 }, {  79,   4,  47, 1 }, {  15,  32, 239, 1 }, { 111,   6,  79, 1 },
    {  47,  66, 239, 1 }, {  79,   4,  47, 1 }, {  79, 100, 239, 1 }, {  47,   2,  15, 1 },
    {  47,  66, 239, 1 }, {  15,   0,  15, 1 }, {  15,  32, 239, 1 }, {  47,   2,  15, 1 }
  };

  d5 = 2; /* Line 167, Address: 0x10020a0 */
  d6 = 0; /* Line 168, Address: 0x10020a8 */
  d7 = 24; /* Line 169, Address: 0x10020ac */
  d0 = (short)(cntplus((unsigned short*)clchgcnt, d5, d6, d7) & 65534); /* Line 170, Address: 0x10020b4 */

  d0 >>= 1; /* Line 172, Address: 0x10020e8 */
  lpPeDest = &lpcolorwk[33]; /* Line 173, Address: 0x10020f0 */
  for (i = 0; i < 5; ++i) { /* Line 174, Address: 0x10020fc */
    *lpPeDest++ = tbl0[d0++]; /* Line 175, Address: 0x1002108 */
  } /* Line 176, Address: 0x1002150 */
} /* Line 177, Address: 0x1002170 */
